//
//  musicViewModel.m
//  音乐播放器
//
//  Created by apple on 16/7/25.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "musicViewModel.h"

@implementation musicViewModel

-(void)setItem:(musicModel *)item
{
    //设置顶部view的frame和cell的高度
    _item = item;
    
    CGFloat margin = 10;
    CGFloat x = 0;
    CGFloat y = 0;
    CGFloat w = HMXScreenW;
    CGFloat h = 280;
    CGFloat picW = w - 2 * margin;
    
    _musicViewFrame = CGRectMake(x, y, w, h);
    _cellH = CGRectGetMaxY(_musicViewFrame) + margin;
    
    //设置最热歌词view的frame和cell的高度
    CGFloat hotLrcX = margin;
    CGFloat hotLrcY = _cellH;
    CGFloat hotLrcW = picW;
    NSString * strHotLrc = _item.hotLrclist;
    CGFloat height = [strHotLrc sizeWithFont:[UIFont systemFontOfSize:15]constrainedToSize:CGSizeMake(145, HUGE)].height ;
    CGFloat hotLrcH = 0;
    if (height <= 60) {
        
        hotLrcH = 80;
    }else{
        
        hotLrcH = height + 20;
    }
    _bottomViewFrame = CGRectMake(hotLrcX, hotLrcY, hotLrcW, hotLrcH);
    _cellH = CGRectGetMaxY(_bottomViewFrame) + margin;
   
   
    //设置最热评论view的frame和cell的高度
    CGFloat hotComX = margin;
    CGFloat hotComY = _cellH;
    CGFloat hotComW = picW;
    NSString * strHotComment = _item.hotCommentlist;
    CGFloat height1 = [strHotComment sizeWithFont:[UIFont systemFontOfSize:15]constrainedToSize:CGSizeMake(145, HUGE)].height ;
    //NSLog(@"%@",strHotComment);
    CGFloat hotComH = 0;
    if (height1 <= 60) {
        
        hotComH = 80;
    }else{
        
        hotComH = height1 + 20;
    }
    //NSLog(@"%lf",height1);
    _hotCommentViewFrame = CGRectMake(hotComX, hotComY, hotComW, hotComH);
    _cellH = CGRectGetMaxY(_hotCommentViewFrame) + margin;
    
    
    //设置评论view的frame和cell的高度
    CGFloat commentX = margin;
    CGFloat commentY = _cellH;
    CGFloat commentW = picW;
    CGFloat commentH = 30;
    
    _commentViewFrame = CGRectMake(commentX, commentY, commentW, commentH);
    _cellH = CGRectGetMaxY(_commentViewFrame) + margin;
    
}

@end
